/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package shapes;

/**
 *
 * @author ctuchsch
 */
public class Cube
{

    private final int numPerVertice = 3;
    private final int numVertices = 6;
    private final int sides = 6;
    private final float x;
    private final float y;
    private final float z;
    private final float width;
    private final float height;
    private final float depth;
    //private float scale;

    public Cube(float x, float y, float z, float width, float height, float depth)
    {
        this.x = x;
        this.y = y;
        this.z = z;
        this.width = width;
        this.height = height;
        this.depth = depth;
    }

    public float[] toFloatArray()
    {
        float[] f = new float[numVertices * sides * numPerVertice];
        float halfWidth = width / 2;
        float halfHeight = height / 2;
        float halfDepth = depth / 2;
        //front
        f[0] = x - halfWidth;
        f[1] = y - halfHeight;
        f[2] = z + halfDepth;

        f[3] = x + halfWidth;
        f[4] = y - halfHeight;
        f[5] = z + halfDepth;

        f[6] = x - halfWidth;
        f[7] = y + halfHeight;
        f[8] = z + halfDepth;

        f[9] = x - halfWidth;
        f[10] = y + halfHeight;
        f[11] = z + halfDepth;

        f[12] = x + halfWidth;
        f[13] = y - halfHeight;
        f[14] = z + halfDepth;

        f[15] = x + halfWidth;
        f[16] = y + halfHeight;
        f[17] = z + halfDepth;

        //right
        f[18] = x + halfWidth;
        f[19] = y - halfHeight;
        f[20] = z + halfDepth;

        f[21] = x + halfWidth;
        f[22] = y - halfHeight;
        f[23] = z - halfDepth;

        f[24] = x + halfWidth;
        f[25] = y + halfHeight;
        f[26] = z + halfDepth;

        f[27] = x + halfWidth;
        f[28] = y + halfHeight;
        f[29] = z + halfDepth;

        f[30] = x + halfWidth;
        f[31] = y - halfHeight;
        f[32] = z - halfDepth;

        f[33] = x + halfWidth;
        f[34] = y + halfHeight;
        f[35] = z - halfDepth;

        //back
        f[36] = x - halfWidth;
        f[37] = y - halfHeight;
        f[38] = z + halfDepth;

        f[39] = x + halfWidth;
        f[40] = y - halfHeight;
        f[41] = z - halfDepth;

        f[42] = x - halfWidth;
        f[43] = y + halfHeight;
        f[44] = z - halfDepth;

        f[45] = x - halfWidth;
        f[46] = y + halfHeight;
        f[47] = z - halfDepth;

        f[48] = x + halfWidth;
        f[49] = y - halfHeight;
        f[50] = z - halfDepth;

        f[51] = x + halfWidth;
        f[52] = y + halfHeight;
        f[53] = z - halfDepth;

        //left
        f[54] = x - halfWidth;
        f[55] = y - halfHeight;
        f[56] = z + halfDepth;

        f[57] = x - halfWidth;
        f[58] = y - halfHeight;
        f[59] = z - halfDepth;

        f[60] = x - halfWidth;
        f[61] = y + halfHeight;
        f[62] = z + halfDepth;

        f[63] = x - halfWidth;
        f[64] = y + halfHeight;
        f[65] = z + halfDepth;

        f[66] = x - halfWidth;
        f[67] = y - halfHeight;
        f[68] = z - halfDepth;

        f[69] = x - halfWidth;
        f[70] = y + halfHeight;
        f[71] = z - halfDepth;

        //top
        f[72] = x - halfWidth;
        f[73] = y + halfHeight;
        f[74] = z - halfDepth;

        f[75] = x + halfWidth;
        f[76] = y + halfHeight;
        f[77] = z - halfDepth;

        f[78] = x - halfWidth;
        f[79] = y + halfHeight;
        f[80] = z + halfDepth;

        f[81] = x - halfWidth;
        f[82] = y + halfHeight;
        f[83] = z + halfDepth;

        f[84] = x + halfWidth;
        f[85] = y + halfHeight;
        f[86] = z - halfDepth;

        f[87] = x + halfWidth;
        f[88] = y + halfHeight;
        f[89] = z + halfDepth;

        //bottom
        f[90] = x - halfWidth;
        f[91] = y - halfHeight;
        f[92] = z - halfDepth;

        f[93] = x + halfWidth;
        f[94] = y - halfHeight;
        f[95] = z - halfDepth;

        f[96] = x - halfWidth;
        f[97] = y - halfHeight;
        f[98] = z + halfDepth;

        f[99] = x - halfWidth;
        f[100] = y - halfHeight;
        f[101] = z + halfDepth;

        f[102] = x + halfWidth;
        f[103] = y - halfHeight;
        f[104] = z - halfDepth;

        f[105] = x + halfWidth;
        f[106] = y - halfHeight;
        f[107] = z + halfDepth;
        
        return f;
    }
}
